﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;

namespace StripSubtitle
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            foreach (var item in Directory.GetFiles(textBox1.Text, "*.srt", SearchOption.TopDirectoryOnly))
            {
                StringBuilder sb = new StringBuilder();
                var rows = File.ReadLines(item);
                foreach (var row in rows)
                {
                    if (row.Length == 0)
                    {
                        continue;
                    }
                    if ((int)row[0] >=(int)'A' && (int)row[0] <=(int)'Z' ||
                        (int)row[0] >=(int)'a' && (int)row[0] <=(int)'z')
                    {
                        sb.Append(row.TrimEnd(new char[] { '\r', '\n' })).Append(" ");
                    }
                }

                File.WriteAllText(item + ".txt", sb.ToString());
            }
        }
    }
}
